package com.android.woodpecker;

import com.android.woodpecker.DatabaseScore.DatabaseHelper;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.TextView;

public class FreePlayResult extends Activity implements OnClickListener {
	TextView resultText;
	Button returnToMain, checkScore;
	Bundle extras;
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.freeplayresult);
		resultText = (TextView) findViewById(R.id.tvResult);
		extras = getIntent().getExtras();
		int score = extras.getInt("total");
		if (extras != null) {
			resultText.setText("Total Score: \n   " + score);
		}
		
		DatabaseScore entry = new DatabaseScore(this);
		entry.Open();
		entry.createEntry(score);
		entry.Close();
		
		returnToMain = (Button) findViewById(R.id.bReturnToMainMenu);
		returnToMain.setOnClickListener(this);

		checkScore = (Button) findViewById(R.id.bCheckScore);
		checkScore.setOnClickListener(this);

	}

	public void onClick(View v) {
		switch (v.getId()) {
		case R.id.bReturnToMainMenu:
			Intent returnToMain = new Intent(this, MainMenu.class);
			startActivity(returnToMain);
			break;
			
		case R.id.bCheckScore:
			Intent checkScore = new Intent(this, CheckScore.class);
			startActivity(checkScore);
			break;
		}
	}

}
